﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BanHangCshap.Class.gkhtdl63.DAL
{
    public abstract class DuanDAL: clsBaseDAL
    {
        public DataTable Duan_LayDanhsach()
        {
            return base.Select("sp_Duan_LayDanhsach");
        }

        public DataTable Duan_LayChonAll()
        {
            return base.Select("sp_Duan_LayChonAll");
        }

        public DataTable Duan_LayChon_Ma_Tho(string Ma_NhanvienLam)
        {
            string xlSPName = "sp_Duan_LayChon_Ma_Tho";
            string[] xlSPPara = { "@Ma_NhanvienLam" };
            object[] xlSPValu = { Ma_NhanvienLam };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_LayTheoId(long xlId)
        {
            string xlSPName = "sp_Duan_LayTheoId";
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { xlId };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_Taoma(string xlPMa)
        {
            string xlSPName = "sp_Duan_Taoma";
            string[] xlSPPara = { "@PMa" };
            string[] xlSPValu = { xlPMa };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_LayChitiet(long xlId)
        {
            string xlSPName = "sp_Duan_LayChitiet";
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { xlId };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_LayTonghopVattu(long xlId)
        {
            string xlSPName = "sp_Duan_XemtonghopVattu";
            string[] xlSPPara = { "@Id_Duan" };
            object[] xlSPValu = { xlId };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_LayChitietVattu(long xlId_Duan)
        {
            string xlSPName = "sp_Duan_XemchitietVattu";
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { xlId_Duan };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_TimNgayTho(DateTime xlTungay, DateTime xlDenngay, string xlMa_NhanvienLam)
        {
            string xlSPName = "sp_Duan_TimNgayTho";
            string[] xlSPPara = { "@Tungay", "@Denngay", "@Ma_NhanvienLam" };
            object[] xlSPValu = { xlTungay, xlDenngay, xlMa_NhanvienLam };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_SosanhVattuDadung(string xlTungay, string xlDenngay, long xlId_Duan)
        {
            string xlSPName = "sp_Duan_SosanhVattuDadung";
            string[] xlSPPara = { "@Tungay", "@Denngay", "@Id_Duan" };
            object[] xlSPValu = { xlTungay, xlDenngay, xlId_Duan };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }


        public DataTable Duan_TimNgay(DateTime xlTungay, DateTime xlDenngay)
        {
            string xlSPName = "sp_Duan_TimNgay";
            string[] xlSPPara = { "@Tungay", "@Denngay" };
            object[] xlSPValu = { xlTungay, xlDenngay };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable DuanInChitiet(long xlId)
        {
            string xlSPName = "sp_DuanInChitiet";
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { xlId };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_Trangthai(long xlId_Duan)
        {
            string xlSPName = "sp_Duan_Trangthai";
            string[] xlSPPara = { "@Id_Duan" };
            object[] xlSPValu = { xlId_Duan };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Duan_Them(DAL.Entities.Duan DA)
        {
            string xlSPName = "sp_Duan_Them";
            string[] xlSPPara = {  
                                   "@Ma"
                                    ,"@Ten"
                                    ,"@Ngaylap"
                                    ,"@Ngaybatdau"
                                    ,"@xNgayhoanthanh"
                                    ,"@Ngayhoanthanh"
                                    ,"@Ma_NhanvienLap"
                                    ,"@Ma_NhanvienLam"
                                    ,"@Ghichu"

                                };

            object[] xlSPValu = {
                                    DA.Ma
                                    ,DA.Ten
                                    ,DA.Ngaylap
                                    ,DA.Ngaybatdau
                                    ,DA.xNgayhoanthanh
                                    ,DA.Ngayhoanthanh
                                    ,DA.Ma_NhanvienLap
                                    ,DA.Ma_NhanvienLam
                                    ,DA.Ghichu

                                 };
            return base.InsertReturnObj(xlSPName, xlSPPara, xlSPValu);
        }

        public bool Duan_Capnhat(DAL.Entities.Duan DA, long IdCu)
        {
            string xlSPName = "sp_Duan_Capnhat";
            string[] xlSPPara = {  
                                "@IdCu"                        
                                ,"@Ma"
                                ,"@Ten"
                                ,"@Ngaylap"
                                ,"@Ngaybatdau"
                                ,"@xNgayhoanthanh"
                                ,"@Ngayhoanthanh"
                                ,"@Ma_NhanvienLap"
                                ,"@Ma_NhanvienLam"
                                ,"@Ghichu"
                                };
            object[] xlSPValu = {   IdCu
                                   ,DA.Ma
                                    ,DA.Ten
                                    ,DA.Ngaylap
                                    ,DA.Ngaybatdau
                                    ,DA.xNgayhoanthanh
                                    ,DA.Ngayhoanthanh
                                    ,DA.Ma_NhanvienLap
                                    ,DA.Ma_NhanvienLam
                                    ,DA.Ghichu
                                 };
            return base.Update(xlSPName, xlSPPara, xlSPValu);
        }

        public bool Duan_Xoa(long Id)
        {
            string xlSPName = "sp_Duan_Xoa";
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { Id};
            return base.Update(xlSPName, xlSPPara, xlSPValu);
        }

        public bool Duan_Capnhat_Ngayhoanthanh(long Id, object Ngayhoanthanh)
        {
            string xlSPName = "sp_Duan_Capnhat_Ngayhoanthanh";
            string[] xlSPPara = { "@Id", "@Ngayhoanthanh" };
            object[] xlSPValu = { Id,Ngayhoanthanh };
            return base.Update(xlSPName, xlSPPara, xlSPValu);
        }
    }
}
